package com.gdth.bank.presenter;

import com.gdth.bank.model.SplashModel;
import com.gdth.bank.utils.LogUtils;
import com.gdth.bank.view.SplashView;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class SplashPresenter implements IBasePresenter {
	
	
	private SplashView mSplashView;
	private SplashModel mSplashModel;
	
	public SplashPresenter(SplashView mSplashView) {
        this.mSplashView = mSplashView;
        mSplashModel = new SplashModel();
       
    }
	
	 /**
     * 
     * @param username
     */
    public void getAppImage(){
    	//mLoginView.showProgressDialog("正在登录...");  	
    	mSplashModel.getAppImage()
			.subscribeOn(Schedulers.io())
			.unsubscribeOn(Schedulers.io())
			.observeOn(AndroidSchedulers.mainThread())
			.subscribe(new Subscriber<String>(){

				@Override
				public void onCompleted() {
					if (!this.isUnsubscribed()) {
			            this.unsubscribe();
			        }
				}
	
				@Override
				public void onError(Throwable arg0) {
					LogUtils.i("________________" , arg0.toString());
				}
	
				@Override
				public void onNext(String arg0) {   // 获取到招聘数据
					// TODO Auto-generated method stub
					// 获取到数据以后 ， 对数据进行保存， 并下载照片
					
	            	mSplashView.getAppImage(arg0);
	            	
				}
		});
    }
	

	@Override
	public void subscribe() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void unsubscribe() {
		// TODO Auto-generated method stub
		
	}

}
